﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HaumDisplay
{
    public class HaumRectangle
    {
        /// <summary>
        /// 矩形
        /// </summary>
        public RectangleF rect;

        private Color _selectColor;
        /// <summary>
        /// 选中颜色
        /// </summary>
        public Color selectColor
        {
            get { return _selectColor; }
        }

        private Color _penColor;
        /// <summary>
        /// 画笔颜色
        /// </summary>
        public Color penColor
        {
            get { return _penColor; }
            set
            {
                _penColor = value;

                int r = 255 - value.R;
                int g = 255 - value.G;
                int b = 255 - value.B;
                _selectColor = Color.FromArgb(r, g, b);
            }
        }

        
        private float _penSize;
        /// <summary>
        /// 画笔大小
        /// </summary>
        public float penSize
        {
            get { return _penSize; }
            set { _penSize = value; }
        }

        /// <summary>
        /// 是否选中
        /// </summary>
        public bool isSelect;

        
        /// <summary>
        /// 获取矩形左上点
        /// </summary>
        /// <returns></returns>
        public PointF GetTL()
        {
            return new PointF(rect.X, rect.Y);
        }

        /// <summary>
        /// 获取矩形右上点
        /// </summary>
        /// <returns></returns>
        public PointF GetTR()
        {
            return new PointF(rect.X + rect.Width, rect.Y);
        }

        /// <summary>
        /// 获取矩形右下点
        /// </summary>
        /// <returns></returns>
        public PointF GetBR()
        {
            float r = rect.X + rect.Width;
            float b = rect.Y + rect.Height;

            return new PointF(r, b);
        }

        /// <summary>
        /// 获取矩形左下点
        /// </summary>
        /// <returns></returns>
        public PointF GetBL()
        {
            return new PointF(rect.X, rect.Y + rect.Height);
        }

        /// <summary>
        /// 获取矩形宽高
        /// </summary>
        /// <returns></returns>
        public SizeF GetSize()
        {
            float w = GetBR().X - GetTL().X ;
            float h = GetBR().Y - GetTL().Y ;

            return new SizeF(w, h);
        }

        /// <summary>
        /// 获取矩形中心点
        /// </summary>
        /// <returns></returns>
        public PointF GetCenter()
        {
            float x = rect.X + rect.Width / 2;
            float y = rect.Y + rect.Height / 2;

            return new PointF(x, y);
        }

        /// <summary>
        /// 获取矩形面积
        /// </summary>
        /// <returns></returns>
        public double GetArea() {
            return rect.Width * rect.Height;
        }

        /// <summary>
        /// 获取矩形周长
        /// </summary>
        /// <returns></returns>
        public double GetPermiter() {
            return (rect.Width + rect.Height) * 2;
        }

    }
}
